/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/



#pragma once

#include "几何数据.h"


														 
/*Inline vec3 operator+(const vec3& a, const float32& b) {
	__m128 a1 = _mm_set_ps(a.x, a.y, a.z, 0.0);							 
	__m128 a2 = _mm_set_ps(b, b, b, b);									 
																		 
	__m128 结果A = _mm_add_ps(a1, a2);									 
	return { 结果A.m128_f32[3], 结果A.m128_f32[2], 结果A.m128_f32[1] };	 
};																		 

Inline vec3 operator+(const vec3& a, const vec3& b) {
	__m128 a1 = _mm_set_ps(a.x, a.y, a.z, 0.0);
	__m128 a2 = _mm_set_ps(b.x, b.y, b.z, 0.0);

	__m128 结果A = _mm_add_ps(a1, a2);

	return { 结果A.m128_f32[3], 结果A.m128_f32[2], 结果A.m128_f32[1] };
};*/



//Inline void operator+=(vec3& a, const vec3& b) {
//	__m128 a1 = _mm_set_ps(a.x, a.y, a.z, 0.0);
//	__m128 a2 = _mm_set_ps(b.x, b.y, b.z, 0);
//
//	a1 = _mm_add_ps(a1, a2);
//	a.x = a1.m128_f32[3];
//	a.y = a1.m128_f32[2];
//	a.z = a1.m128_f32[1];
//};





/*Inline vec3 operator-(const vec3& a, const float32& b) {
	__m128 a1 = _mm_set_ps(a.x, a.y, a.z, 0.0);
	__m128 a2 = _mm_set_ps(b, b, b, 0.0);

	__m128 结果A = _mm_sub_ps(a1, a2);

	return { 结果A.m128_f32[3], 结果A.m128_f32[2], 结果A.m128_f32[1] };
};

Inline vec3 operator-(const vec3& a, const vec3& b) {
	__m128 a1 = _mm_set_ps(a.x, a.y, a.z, 0.0);
	__m128 a2 = _mm_set_ps(b.x, b.y, b.z, 0.0);

	__m128 结果A = _mm_sub_ps(a1, a2);

	return { 结果A.m128_f32[3], 结果A.m128_f32[2], 结果A.m128_f32[1] };
};

inline vec3 operator-(const uvec3& a, const float32 b) {
	__m128 a1 = _mm_set_ps(a.x, a.y, a.z, 0.0);
	__m128 a2 = _mm_set_ps(b, b, b, 0.0);

	__m128 结果A = _mm_sub_ps(a1, a2);

	return { 结果A.m128_f32[3], 结果A.m128_f32[2], 结果A.m128_f32[1] };
};*/

Inline vec3 operator-(const uvec3& a, const vec3& b) {
	return { a.x - b.x, a.y - b.y, a.z - b.z };
};

Inline uvec3 operator-(const uvec3& a, const uvec3& b) {
	return { a.x - b.x, a.y - b.y, a.z - b.z };
};

Inline uvec4 operator-(const uvec4& a, const uvec4& b) {
	return { a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w };
};


Inline vec3 operator-(const uvec3& a, const float32 b) {
	return { a.x - b, a.y - b, a.z - b };
};





/*Inline vec3 operator*(const vec3& a, const float32& b) {
	__m128 a1 = _mm_set_ps(a.x, a.y, a.z, 0.0);
	__m128 a2 = _mm_set_ps(b, b, b, 0.0);

	__m128 寄存器结果A = _mm_mul_ps(a1, a2);

	return { 寄存器结果A.m128_f32[3], 寄存器结果A.m128_f32[2], 寄存器结果A.m128_f32[1] };
};

inline vec3 operator*(const vec3& a, const vec3& b) {
	__m128 a1 = _mm_set_ps(a.x, a.y, a.z, 0.0);
	__m128 a2 = _mm_set_ps(b.x, b.y, b.z, 0.0);

	__m128 寄存器结果A = _mm_mul_ps(a1, a2);

	//float32 r[4];
	//_mm_storer_ps(r, 寄存器结果A);
	//return { r[0], r[1], r[2] };
	return { 寄存器结果A.m128_f32[3], 寄存器结果A.m128_f32[2], 寄存器结果A.m128_f32[1] };
};*/

inline vec4 operator*(const vec4& a, const float32& b) {
	__m128 a1 = _mm_set_ps(a.x, a.y, a.z, a.w);
	__m128 a2 = _mm_set_ps(b, b, b, b);

	__m128 结果A = _mm_mul_ps(a1, a2);

	return { 结果A.m128_f32[3], 结果A.m128_f32[2], 结果A.m128_f32[1], 结果A.m128_f32[0] };
};



/*inline void operator*=(vec3& a, const float32& b) {
	__m128 a1 = _mm_set_ps(a.x, a.y, a.z, 0.0);
	__m128 a2 = _mm_set_ps(b, b, b, 0.0);

	__m128 寄存器结果A = _mm_mul_ps(a1, a2);

	a.x = 寄存器结果A.m128_f32[3];
	a.y = 寄存器结果A.m128_f32[2];
	a.z = 寄存器结果A.m128_f32[1];
};*/









inline vec3 operator/(const vec3& a, const float32& b) {
	__m128 a1 = _mm_set_ps(a.x, a.y, a.z, 0.0);
	__m128 a2 = _mm_set_ps(b, b, b, 0.0);

	__m128 寄存器结果A = _mm_div_ps(a1, a2);

	return { 寄存器结果A.m128_f32[3], 寄存器结果A.m128_f32[2], 寄存器结果A.m128_f32[1] };
};

inline void operator/=(vec3& a, const float32& b) {
	__m128 a1 = _mm_set_ps(a.x, a.y, a.z, 0.0);
	__m128 a2 = _mm_set_ps(b, b, b, 0.0);

	a2 = _mm_div_ps(a1, a2);

	a.x = a2.m128_f32[3];
	a.y = a2.m128_f32[2];
	a.z = a2.m128_f32[1];
};

inline vec3 operator/(const vec3& a, const vec3& b) {
	__m128 a1 = _mm_set_ps(a.x, a.y, a.z, 0.0);
	__m128 a2 = _mm_set_ps(b.x, b.y, b.z, 0.0);

	__m128 结果A = _mm_div_ps(a1, a2);

	return { 结果A.m128_f32[3], 结果A.m128_f32[2], 结果A.m128_f32[1] };
};

//inline vec3 operator/(const vec3& a, const uvec3& b) {
//	__m128 a1 = _mm_set_ps(a.x, a.y, a.z, 0.0);
//	__m128 a2 = _mm_set_ps(b.x, b.y, b.z, 0.0);
//
//	__m128 结果A = _mm_div_ps(a1, a2);
//
//	return { 结果A.m128_f32[3], 结果A.m128_f32[2], 结果A.m128_f32[1] };
//};

//Inline vec2 operator/(const vec2& a, const uvec2 b) {
//	return { a.x / b.x, a.y / b.y };
//};











//Inline vec2 operator+(const vec2& a, const float& b) {
//	return { a.x + b, a.y + b };
//};
//Inline vec2 operator+(const vec2& a, const vec2& b) {
//	return { a.x + b.x, a.y + b.y };
//};
//Inline vec2 operator-(const vec2& a, const float& b) {
//	return { a.x - b, a.y - b };
//};



/*Inline vec2 operator+(const vec2& a, const float32& b) {
	__m128 a1 = _mm_set_ps(a.x, a.y, 0.0f, 0.0f);
	__m128 a2 = _mm_set_ps(b, b, b, b);

	__m128 结果A = _mm_add_ps(a1, a2);

	return { 结果A.m128_f32[3], 结果A.m128_f32[2] };
};

Inline vec2 operator+(const vec2& a, const vec2& b) {
	__m128 a1 = _mm_set_ps(a.x, a.y, 0.0f, 0.0f);
	__m128 a2 = _mm_set_ps(b.x, b.y, 0.0f, 0.0f);

	__m128 结果A = _mm_add_ps(a1, a2);

	return { 结果A.m128_f32[3], 结果A.m128_f32[2] };
};

Inline vec2 operator-(const vec2& a, const float32& b) {
	__m128 a1 = _mm_set_ps(a.x, a.y, 0, 0);
	__m128 a2 = _mm_set_ps(b, b, b, b);

	__m128 结果A = _mm_sub_ps(a1, a2);

	return { 结果A.m128_f32[3], 结果A.m128_f32[2] };
};

Inline vec2 operator*(const vec2& a, const float32& b) {
	__m128 a1 = _mm_set_ps(a.x, a.y, 0, 0);
	__m128 a2 = _mm_set_ps(b, b, 0, 0);

	__m128 寄存器结果A = _mm_mul_ps(a1, a2);

	return { 寄存器结果A.m128_f32[3], 寄存器结果A.m128_f32[2] };
};

Inline vec2 operator*(const vec2& a, const vec2& b) {
	__m128 a1 = _mm_set_ps(a.x, a.y, 0, 0.0);
	__m128 a2 = _mm_set_ps(b.x, b.y, 0, 0.0);

	__m128 寄存器结果A = _mm_mul_ps(a1, a2);

	return { 寄存器结果A.m128_f32[3], 寄存器结果A.m128_f32[2] };
};

inline vec2 operator/(const vec2& a, const vec2& b) {
	__m128 a1 = _mm_set_ps(a.x, a.y, 0, 0.0);
	__m128 a2 = _mm_set_ps(b.x, b.y, 0, 0.0);

	__m128 结果A = _mm_div_ps(a1, a2);

	return { 结果A.m128_f32[3], 结果A.m128_f32[2] };
};

inline vec2 operator/(const vec2& a, const float32& b) {
	__m128 a1 = _mm_set_ps(a.x, a.y, 0, 0.0);
	__m128 a2 = _mm_set_ps(b, b, 0, 0.0);

	__m128 寄存器结果A = _mm_div_ps(a1, a2);

	return { 寄存器结果A.m128_f32[3], 寄存器结果A.m128_f32[2] };
};
*/


